<?php
/**
 * User: Mykola B.
 * Date: 3/1/13
 * Time: 6:53 PM
 */
class Router
{
    public function __construct($f3) {
        $this->f3 = $f3;
        $this->route();
    }

    private function route() {
        $f3 = $this->f3;
        $userController = new \controllers\UserController();

        $f3->set('is_authenticated', $userController->isAuthenticated($f3));
        $f3->set('has_google_map', false);

        $f3->route('GET /', 'controllers\DefaultController->homeGet');
        $f3->route('POST /', 'controllers\DefaultController->homePost');

        $f3->route('GET /login', 'controllers\UserController->loginGet');
        $f3->route('POST /login', 'controllers\UserController->loginPost');
        $f3->route('GET /logout', 'controllers\UserController->logout');

        $f3->route('GET /dbparams', 'controllers\AdminController->dbParamsGet');
        $f3->route('POST /dbparams', 'controllers\AdminController->dbParamsPost');
        $f3->route('POST /rename_tables', 'controllers\AdminController->dbRenameTables');

        $f3->route('GET /visualparams', 'controllers\AdminController->visualisationParamsGet');
        $f3->route('POST /visualparams', 'controllers\AdminController->visualisationParamsPost');
    }
}
